<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>会员登录 - {siteseo name='title'}</title>
    <link href="__USERST__static/css/dgy.base.css" rel="stylesheet" type="text/css">
    <link href="__USERST__static/css/dgy.login.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__USERST__static/js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="__USERST__static/layer/layer.js"></script>
    <link rel="stylesheet" href="__USERST__static/layer/theme/default/layer.css?v=3.1.1" id="layuicss-layer">
    <style type="text/css" media="all">
    .loginicon{
    width: 20px;
    height: 20px;
    display: inline-block;
    background-size: 100% 100%;
    position: absolute;
    }
    </style>
  </head>
  <body>
    <div class="dogo_loginwp">
            <a class="dogo_logo" href="/">
                <img src="{siteseo name='logo'}" class="logo">
            </a>
	      <div class="midgroup">
	           <div class="loginwrap loginwarrp">
                    <div class="logingroup login_form">
            			<form action="/" method="post" onsubmit="return checkall(this)">
            				
                            <section>
                            	<input type="text" placeholder="请输入用户名、邮箱、手机号码" class="input_block login_account" name="account" id="account" value="{$Think.session.username}">
                            </section>
                            <section>
                            	<input type="password" placeholder="请输入密码" class="input_block login_account" name="password" id="password" value="">
                            </section>
							<section class="qrcode" id="yzm">
                            	<input type="text" placeholder="请输入验证码" class="input_block login_code" required="" name="verif" id="captcha">
                            	<img id="verif_img" src="{:captcha_src()}" onclick="this.src=this.src+'?'+Math.random()" class="qrcode verifyimg" title="看不清，换一张">
                            </section>
                            <!-- {if !empty($Think.session.userpwd_error)}
                            <section class="qrcode" id="yzm">
                            	<input type="text" placeholder="请输入验证码" class="input_block login_code" required="" name="verif" id="captcha">
                            	<img id="verif_img" src="{:captcha_src()}" onclick="this.src=this.src+'?'+Math.random()" class="qrcode verifyimg" title="看不清，换一张">
                            </section>
                            {/if} -->
                            <input type="checkbox" name="ispassword" id="ispassword" value="记住密码" />
                            <span>&nbsp;记住密码</span>
                            <input type="submit" class="loginbtn" id="dosubmit" name="dosubmit" value="立即登录">
                            <section style="background:none; margin-top:10px; border:0;">
                                还没有会员，<a href="{:url('index/Index/reg')}" style="color:#409eff;">立即注册</a>
                                <a href="{:url('index/Index/password')}" style="float:right;">忘记密码？</a>
                                <div class="clearfix"></div>
                            </section>
                        </form>
                        <footer style="text-align:center;">
                            {foreach $ulogin as $l}
                            <a href="{$l.url}"><em class="loginicon" style="background-image:url(/public/images/loginico/{$l.type}.svg);"></em><span style="padding-left: 22px;">{$l.name}</span></a>
                            {/foreach}
						    <p>一个简洁、轻量、实用的内容管理系统！</p>
                        </footer>
                    </div>
	           </div>
	      </div>
	</div>
	
    <div class="footerInfo">
        <p>Copyright ©2020 <a href="/" target="_blank">{siteseo name='title'}</a> All Rights Reserved.</p>
    </div>
    <script type="text/javascript" src="__USERST__static/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="__USERST__static/js/jquery.base64.js"></script>
  <script type="text/javascript">
  
	function setCookie() {
		var loginCode = $("#account").val(); //获取用户名信息
		var pwd = $("#password").val(); //获取登陆密码信息 
		var checked = $("input[type='checkbox']").is(':checked'); //获取“是否记住密码”复选框 
		if (checked) { //判断是否选中了“记住密码”复选框
			//设置cookie过期时间
			var date = new Date();
			date.setTime(date.getTime() + 60*60*24*7 * 1000); //只能这么写，60表示60秒钟,这里默认保存7天
			$.cookie("login_code", loginCode, {
				expires: date,
				path: '/'
			}); //调用jquery.cookie.js中的方法设置cookie中的用户名 
			$.cookie("pwd", $.base64.encode(pwd), {
				expires: date,
				path: '/'
			}); //调用jquery.cookie.js中的方法设置cookie中的登陆密码，并使用base64（jquery.base64.js）进行加密
		} else {
			$.cookie("login_code", null);
			$.cookie("pwd", null);
		}
	}
	
	//清除所有cookie函数
	function clearAllCookie() {
		var date = new Date();
		date.setTime(date.getTime() - 10000);
		var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
		if (keys) {
			for (var i = keys.length; i--;)
				document.cookie = keys[i] + "=0; expire=" + date.toGMTString() + "; path=/";
		}
	}
    
	//获取cookie	
    $(function(){
    		var loginCode = $.cookie("login_code"); //获取cookie中的用户名
		var pwd = $.cookie("pwd"); //获取cookie中的登陆密码 
		if (!loginCode || loginCode == 0) {
			return false;
		} else {
			$("#account").val(loginCode);
		}
		if (!pwd || pwd == 0) {
			return false;
		} else {
			//密码存在的话把密码填充到密码文本框
			$("#password").val($.base64.decode(pwd));
			//密码存在的话把“记住用户名和密码”复选框勾选住
			$("[name='ispassword']").attr("checked", "true");
		}
    });
  
  
  
      function checkall(obj) {
			 var username=$("#account").val();
			if( username== ''){
				layer.msg('用户名不能为空！', {icon:2,time: 1000});
				$("#account").focus();
				return false;
			}
			if(username.length < 6){
				    layer.msg('用户名低于6位！', {icon:2,time: 1000});
				    $("#account").focus();
				return false;
				}
				var captcha=$("#captcha").val();
            if( captcha== ''){
				layer.msg('验证码不能为空！', {icon:2,time: 1000});
				$("#captcha").focus();
				return false;
			}
			var password = $("#password").val();
			if(password.length < 6 ){
				layer.msg('密码不能低于6位！', {icon:2,time: 1000});
				$("#password").focus();
				return false;
			}
		    //判断是否选中复选框，如果选中，添加cookie 
		    var jizhupwd = $("input[type='checkbox']").is(':checked');
		    if (jizhupwd) {
			    //添加cookie 
				setCookie();
			} else {
				clearAllCookie();
			}
			var dosubmit = false;
			$.ajax({   
				type: "post",   
				url: "{:url('index/Index/login')}",   
				dataType: "json",
				async: false,
				data:  $(obj).serialize(),
				success: function(msg){  
					if(msg.code == 1){
						layer.msg(msg.msg, {icon:1,time: 3000}, function() {
							if(msg.url) location.href = msg.url;
							});
					}else{
						if(msg.code == 0){
						    layer.msg(msg.msg, {icon:2,time: 2000},function(){
						        location.reload();
						    });
						}
						
					}				 
				} 
			});
			return dosubmit ? true : false;
		}
      
  </script>
</body></html>